package com.storm;

import com.storm.bolt.MaxBolt;
import com.storm.bolt.MidBolt;
import com.storm.bolt.MinBolt;
import com.storm.spout.NumSpout;
import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.generated.StormTopology;
import org.apache.storm.topology.TopologyBuilder;

public class App {
    public static void main(String[] args) {
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("mySpout",new NumSpout());
        builder.setBolt("minBolt",new MinBolt(),3).allGrouping("mySpout","min");
        builder.setBolt("midBolt",new MidBolt(),3).allGrouping("mySpout","mid");
        builder.setBolt("maxBolt",new MaxBolt()).allGrouping("mySpout","max");
        StormTopology topology = builder.createTopology();
        Config config = new Config();
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("appStorm",config,topology);

        try {
            Thread.sleep(10000);
            cluster.killTopology("appStorm");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
